package com.riant.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @Classname TestFrowardController
 * @Description TODO
 * @Date 2022/5/1 2:58
 * @Created by 张斌
 */
@Controller
public class TestFrowardController {

    private final Logger logger = LoggerFactory.getLogger(TestController.class);
    @RequestMapping(path = "/testForward1",method = RequestMethod.GET)
    public String test(){
        logger.info("通过跳转转发到success.jsp");
        //forward：转发带/，则会变为//springmvc_demo01/WEB-INF/view/success.jsp
        return "forward:/WEB-INF/view/success.jsp";
    }
//    @RequestMapping(path = "/test1",method = RequestMethod.GET)
//    public String test1(@RequestParam String name){
//        logger.info("name:{}",name);
//        return "success";
//    }

    @RequestMapping(path = "/testForward2",method = RequestMethod.GET)
    public String test2(){
        logger.info("通过跳转转发到success.jsp");
        //这种转发会再次发起一个//springmvc_demo01/success的请求，只不过不会反回到客户端
        return "forward:success";
    }
    @RequestMapping(path = "/success",method = RequestMethod.GET)
    public String test3(){
        logger.info("success.jsp请求");
        return "success";
    }
}
